//
//$Id: gridmin_sa.h 354 2010-03-09 17:29:03Z Oleg.Bulychov $
#pragma once

#include "projects/gridmin/gridmin.h"
#include "solvers/sa/sa_common.h"

//__________________________________________________________________________________
template<>
struct solution<GridMin_Solution, sa_tag>:
    public GridMin_Solution
{
public:
    template<class E>
    void move(E* env, uniform_random& rnd, double probability)
    {
        for (size_t i = 0; i < grids_set_.size(); ++i)
            if (rnd.next_Double() < probability)
            {
                if (grids_set_[i] == 0)   // add grid
                {
                    grids_set_[i] = 1;
                    inc_Hits(env, i);
                    changed_ = true;
                }
                else                      // remove grid
                {
                    bool ok = dec_Hits(env, i);
                    if (ok)
                    {
                        grids_set_[i] = 0;
                        changed_ = true;
                    }
                    else
                        inc_Hits(env, i);
                }
            }
    }
};
//__________________________________________________________________________________

//EOF!
